//
// Created by dw on 2021/8/12.
//
#include <iostream>
#include <iterator>
#include <cmath>
#include <vector>
using namespace std;

template<class T>
void permutations(T list[], int k, int m) {//generate list[k:m] full array
  if (k == m) {// list[k:m] only one full array
    copy(list, list + m + 1, ostream_iterator<T>(cout, " "));
    // std::copy(iterator source_first, iterator source_end, iterator target_start);
    cout << endl;
  } else {//list has multiple array
    for (int i = k; i <= m; i++) {
      swap(list[k], list[i]);
      permutations(list, k + 1, m);
      swap(list[k], list[i]);
    }
  }
}

int main(int argc, char **argv) {
//  int a[10] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19};
  char a[] = "abc";
  permutations(a, 0, 2);
  return 0;
}
